<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>订单详情</title>
    <!-- jquery -->
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <!-- bootstrap -->
    <link rel="stylesheet" type="text/css"
          href="/bootstrap/css/bootstrap.min.css"/>
    <script type="text/javascript" src="/bootstrap/js/bootstrap.min.js"></script>
    <!-- layer -->
    <script type="text/javascript" src="/layer/layer.js"></script>
    <!-- common.js -->
    <script type="text/javascript" src="/js/common.js"></script>

    <!--网页的图标-->
    <link rel="icon" th:href="@{/images/favicon2.ico}">
    <!--全局样式-->
    <link rel="stylesheet" th:href="@{/css/reset.css}">
    <!--字体图标-->
    <link rel="stylesheet" th:href="@{/css/iconfont.css}">
    <!--自己的样式-->
    <link rel="stylesheet" th:href="@{/css/mi.css}">
    <style>
        .box-a,box-b{
            height: 300px;
            float: left;
        }
        .box-a{
            width: 300px;
            border: none;
        }
        .box-b{
            width: 2000px;
            border: none;
            margin-left: 20px;
        }
    </style>
</head>
<body>
<div class="panel panel-default">
    <div class="panel-heading">秒杀订单详情</div>
    <div class="container">
        <div class="home-banner-box">
            <img src="/images/wrap1.png" alt="">
        </div>
        <br>

        <div class="table" id="order">
            <div class="box-a">
                <img id="goodsImg" width="200" height="200"/>
            </div>
            <div class="box-b">
                <h3 id="goodsName"></h3>
                    <table style="width: 500px;font-size: 16px">
                        <tr>
                            <td>订单价格:</td>
                            <td colspan="2" id="goodsPrice"></td>
                        </tr>
                        <tr>
                            <td>下单时间:</td>
                            <td id="createDate" colspan="2"></td>
                        </tr>
                        <tr>
                            <td>收货人:</td>
                            <td colspan="2" id="userNickname"></td>
                        </tr>
                        <tr>
                            <td>电话:</td>
                            <td colspan="2" id="userId"></td>
                        </tr>
                        <tr>
                            <td>收货地址:</td>
                            <td colspan="2" id="userAddress"></td>
                        </tr>
                        <tr>
                            <td>订单状态:</td>
                            <td id="status"></td>
                        </tr>
                        <tr>
                            <td>
                                <button class="btn btn-primary btn-block" type="submit" id="payButton">立即支付</button>
                            </td>
                        </tr>
                    </table>
            </div>
        </div>

        <br>
        <div class="home-banner-box">
            <img src="/images/wrap1.png" alt="">
        </div>
    </div>
</div>
<script>
    $(function () {
        getOrderDetail();
    });
    function getOrderDetail() {
        var orderId = g_getQueryString("orderId");
        $.ajax({
            url: "/order/detail",
            type: "GET",
            data: {
                orderId: orderId
            },
            success: function (data) {
                if (data.code == 200) {
                    render(data.obj);
                } else {
                    layer.msg(data.message);
                }
            },
            error: function () {
                layer.msg("客户端请求错误")
            }
        })
    }
    function render(detail) {
        var goods = detail.goodsVo;
        var order = detail.order;
        $("#goodsName").text(goods.goodsName);
        $("#goodsImg").attr("src", goods.goodsImg);
        $("#goodsPrice").text(order.goodsPrice);
        $("#createDate").text(new Date(order.createDate).format("yyyy-MM-dd HH:mm:ss"));
        $("#userAddress").text(order.userAddress);
        $("#userNickname").text(order.userNickname);
        $("#userId").text(order.userId);
        var status = order.status;
        var statusText = ""
        switch (status) {
            case 0:
                statusText = "未支付";
                break;
            case 1:
                statusText = "待发货";
                break;
            case 2:
                statusText = "已发货";
                break;
            case 3:
                statusText = "已收货";
                break;
            case 4:
                statusText = "已退款";
                break;
            case 5:
                statusText = "已完成";
                break;
        }
        $("#status").text(statusText);
    }
</script>
</body>
</html>